package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISystemLogService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("systemlog")
public class SystemLogController {

    @Autowired
    ISystemLogService systemLogService;

    @RequestMapping("view")
    @RequiresPermissions(value = {"systemLog:view","日志页面"},logical = Logical.OR)
    public String view() {
        return "systemlog";
    }

    @RequestMapping("query")
    @ResponseBody
    @RequiresPermissions(value = {"systemLog:query","日志列表"},logical = Logical.OR)
    public PageResult query(QueryObject qo) {
        return systemLogService.query(qo);
    }

    @RequestMapping("delete")
    @ResponseBody
    @RequiresPermissions(value = {"systemLog:delete","日志删除"},logical = Logical.OR)
    public JsonResult delete(Long id) {
        try {
            systemLogService.deleteById(id);
            return JsonResult.success("");
        } catch (Exception e) {
            e.printStackTrace();
            return JsonResult.mark("操作失败");
        }
    }
}
